#!/bin/bash
set -x
OSDP_PATH=/opt/osdp-conformance
CMDPATH=${OSDP_PATH}/tmp/open_osdp_command.json
CMDPATHX=${OSDP_PATH}/run/CP/open_osdp_command.json

#OUI=5c2623
OUI=007532
CMD_CHALLENGE=20

#020100000210079e0001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00fdd22d23404365d31d5f1b26ab15d66be53a886bf873b051f31c27221f56f257
DETAILS_CHALLENGE=\
020100000201079e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001

#DETAILS_CHALLENGE=\
#020100000201079E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#DETAILS_CHALLENGE=\
#02010000D200079E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#DETAILS_CHALLENGE2=\
#0201D2003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#DETAILS_CHALLENGE=\
#020100008200079E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#DETAILS_CHALLENGE2=\
#0201820800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000


echo  >${CMDPATH} "{"
echo >>${CMDPATH} "  \"command\" : \"mfg\","
echo >>${CMDPATH} "  \"oui\" : \"${OUI}\","
echo >>${CMDPATH} "  \"command-id\" : \"${CMD_CHALLENGE}\","
echo >>${CMDPATH} "  \"command-specific-data\" : \"${DETAILS_CHALLENGE}\""
echo >>${CMDPATH} "}"
sudo -n cp ${CMDPATH} ${CMDPATHX}
ls -l ${CMDPATHX}
sudo -n ${OSDP_PATH}/bin/HUP-CP 

#sleep 8
#/opt/osdp-conformance/run/CP/ch-part2&

#sleep 9
#echo  >${CMDPATH} "{"
#echo >>${CMDPATH} "  \"command\" : \"mfg\","
#echo >>${CMDPATH} "  \"oui\" : \"${OUI}\","
#echo >>${CMDPATH} "  \"command-id\" : \"${CMD_CHALLENGE}\","
#echo >>${CMDPATH} "  \"command-specific-data\" : \"${DETAILS_CHALLENGE2}\""
#echo >>${CMDPATH} "}"
#echo ----
#ls -l ${CMDPATH} ${CMDPATHX}
#ls -l ${CMDPATHX}
#sudo -n ${OSDP_PATH}/bin/HUP-CP 

